home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / snip9503 / jmalloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-14  |  5.9 KB  |  144 lines

  1. /*--------------------------------------------------------------*/
  2. /* Debugging extension by Jeff Dunlop                           */
  3. /* Copyright 1992-1993, DB/Soft Publishing Co.                  */
  4. /* License is hereby granted for use of JMalloc as a debugging  */
  5. /* aid in any program.  JMalloc may not be sold or distributed  */
  6. /* as or part of any for-profit debugging program or library    */
  7. /* nor may it be included in any for-profit library that offers */
  8. /* debugging features.  Any redistribution of JMalloc source    */
  9. /* must include this copyright notice.                          */
  10. /*--------------------------------------------------------------*/
  11.  
  12. /*------------------------[ jmalloc.h ]----------------------------*/
  13. /*                   main header file for jmalloc                  */
  14. /*-----------------------------------------------------------------*/
  15.  
  16. /*--------------------------------------------------------------*/
  17. /*---------------------------[ defines ]------------------------*/
  18. /*--------------------------------------------------------------*/
  19. #ifndef _jmalloc
  20. #   define _jmalloc
  21.  
  22. #define FALSE 0
  23. #define TRUE 1
  24.  
  25. #define CKBYT 1
  26. #define DIRTY 2
  27.  
  28. void db_prn(char *fmt, ...);
  29. #define DBUG_ENTER(a)
  30. #define DBUG_RETURN(a) return(a)
  31. #define DBUG_PRINT(a, b) db_prn b
  32. #define DBUG_PUSH(a)
  33. #define DBUG_VOID_RETURN return
  34.  
  35. /*--------------------------------------------------------------*/
  36. /*------------------------[ structures ]------------------------*/
  37. /*--------------------------------------------------------------*/
  38.  
  39. typedef struct mlist
  40. {
  41.     struct mlist *NextLink;         /* link to next struct */
  42.     char *MAddr;                    /* address assigned    */
  43.     unsigned MSize;                 /* size allocated      */
  44.     char MFile[20];                 /* Allocation file name */
  45.     int MLine;                      /* Allocation line number */
  46. } MLINK;
  47.  
  48. /*--------------------------------------------------------------*/
  49. /*--------------------[ public prototypes ]---------------------*/
  50. /*--------------------------------------------------------------*/
  51.  
  52. #ifdef __cplusplus
  53.    extern   "C"   {
  54. #endif
  55.  
  56. #define JCheckStr(a) j_checkstr((a))
  57.  
  58. int j_checkstr(MLINK *str);
  59.  
  60. #ifdef DBUG
  61.  
  62. #define dr(a) j_deref(a, __FILE__, __LINE__)
  63.  
  64. #define JStrnSet(a, b, c) j_strnset((a), (b), (c), __FILE__, __LINE__)
  65. #define JStrDup(a) j_strdup((a), __FILE__, __LINE__)
  66. #define JStrCat(a, b) j_strcat((a), (b), __FILE__, __LINE__)
  67. #define JMalloc(a) j_malloc((a), __FILE__, __LINE__)
  68. #define JCalloc(a, b) j_calloc((a), (b), __FILE__, __LINE__)
  69. #define AStrCpy(a, b) a_strcpy((a), (b), sizeof (a), __FILE__, __LINE__)
  70. #define AStrCat(a, b) a_strcat((a), (b), sizeof (a), __FILE__, __LINE__)
  71. #define AStrnCpy(a, b, c) a_strncpy((a), (b), (c), sizeof (a), __FILE__, __LINE__)
  72. #define AStrnSet(a, b, c) a_strnset((a), (b), (c), sizeof (a), __FILE__, __LINE__)
  73. #define JFree(a) j_free(a, __FILE__, __LINE__)
  74. #define JStrCpy(a, b) j_strcpy((a), (b), __FILE__, __LINE__)
  75. #define JStrnCpy(a, b, c) j_strncpy((a), (b), (c), __FILE__, __LINE__)
  76. #define JMemCpy(a, b, c) j_memcpy((a), (b), (c), __FILE__, __LINE__)
  77. #define JMemSet(a, b, c) j_memset((a), (b), (c), __FILE__, __LINE__)
  78. #define JMemcheck(a) j_memcheck((a))
  79. #define AMemCpy(a, b, c) a_memcpy((a), (b), (c), sizeof (a), __FILE__, __LINE__)
  80. #define AMemSet(a, b, c) a_memset((a), (b), (c), sizeof (a), __FILE__, __LINE__)
  81. #define JRealloc(a, b) j_realloc((a), (b), __FILE__, __LINE__)
  82.  
  83. void *j_deref(void *a, char *file, int line);
  84. char *j_strnset(char *str, int ch, size_t n, char *file, int line);
  85. char *j_strdup(char *str, char *file, int line);
  86. char *j_strcat(char *__dest, char *__src, char *file, int line);
  87. void *j_malloc(unsigned size, char *file, int line);
  88. void *j_calloc(unsigned size, unsigned sizeach, char *file, int line);
  89. int j_memcheck(int CheckFree);
  90. void j_free(void *AllocAddr, char *file, int line);
  91. char *j_strcpy(char *__dest, const char *__src, char *file, int line);
  92. char *j_strncpy(char *__dest, const char *__src, size_t maxlen, char *file,
  93.                 int line);
  94. void *j_realloc(void *addr, unsigned Size, char *file, int line);
  95. void *j_memset(void *dest, int ch, size_t n, char *file, int line);
  96. void *j_memcpy(void *dest, const void *src, size_t n, char *file, int line);
  97. char *a_strcpy(char *__dest, const char *__src, int size, char *file,
  98.                int line);
  99. char*a_strcat(char *dest, const char *src, int size, char *file, int line);
  100. void *a_memcpy(void *dest, const void *src, size_t n, int size, char *file,
  101.              int line);
  102. void *a_memset(void *dest, int ch, size_t n, int size, char *file, int line);
  103. char *a_strncpy(char *__dest, const char *__src, size_t maxlen, int size,
  104.     char *file, int line);
  105. char *a_strnset(char *str, int ch, size_t n, int size, char *file, int line);
  106.  
  107.  
  108. #else
  109.  
  110. #define dr(a) (a)
  111.  
  112. #define JStrnSet(a, b, c) strnset((a), (b), (c))
  113. #define JStrDup(a) strdup((a))
  114. #define JStrCat(a, b) strcat((a), (b))
  115. #define JMalloc(a) malloc((a))
  116. #define JCalloc(a, b) calloc((a), (b))
  117. #define JFree(a) free(a)
  118. #define JStrCpy(a, b) strcpy((a), (b))
  119. #define JStrnCpy(a, b, c) strcpy((a), (b), (c))
  120. #define JMemCpy(a, b, c) memcpy((a), (b), (c))
  121. #define JMemSet(a, b, c) memset((a), (b), (c))
  122. #define JMemcheck(a)
  123. #define JRealloc(a, b) realloc((a), (b))
  124.  
  125. #define AStrCpy(a, b) strcpy((a), (b))
  126. #define AStrCat(a, b) strcat((a), (b))
  127. #define AStrnCpy(a, b, c)  strncpy((a), (b), (c))
  128. #define AStrnSet(a, b, c), strnset((a), (b), (c))
  129. #define AMemCpy(a, b, c) memcpy((a), (b), (c))
  130. #define AMemSet(a, b, c) memset((a), (b), (c))
  131.  
  132. #endif
  133.  
  134. #ifdef __cplusplus
  135.    }
  136. #endif
  137.  
  138. /*--------------------------------------------------------------*/
  139. /*---------------------[ public variables ]---------------------*/
  140. /*--------------------------------------------------------------*/
  141.  
  142. extern MLINK *MalTop;
  143. #endif
  144.